<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="C," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="stm32f0 寄存器配置 外部中断捕获  1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939">
<meta name="keywords" content="C">
<meta property="og:type" content="article">
<meta property="og:title" content="stm32 寄存器配置">
<meta property="og:url" content="http://yoursite.com/2017/08/19/stm32-寄存器配置/index.html">
<meta property="og:site_name" content="linghaibin-Blog">
<meta property="og:description" content="stm32f0 寄存器配置 外部中断捕获  1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939">
<meta property="og:updated_time" content="2017-08-20T09:04:51.249Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="stm32 寄存器配置">
<meta name="twitter:description" content="stm32f0 寄存器配置 外部中断捕获  1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/08/19/stm32-寄存器配置/"/>





  <title>stm32 寄存器配置 | linghaibin-Blog</title>
  














</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">linghaibin-Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">坚持 坚持 坚持 ！！！</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-tags " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/08/19/stm32-寄存器配置/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="linghaibin">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="linghaibin-Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">stm32 寄存器配置</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-08-19T11:03:56-07:00">
                2017-08-20
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/stm32/" itemprop="url" rel="index">
                    <span itemprop="name">stm32</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="stm32f0-寄存器配置"><a href="#stm32f0-寄存器配置" class="headerlink" title="stm32f0 寄存器配置"></a>stm32f0 寄存器配置</h1><ul>
<li>外部中断捕获</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div><div class="line">151</div><div class="line">152</div><div class="line">153</div><div class="line">154</div><div class="line">155</div><div class="line">156</div><div class="line">157</div><div class="line">158</div><div class="line">159</div><div class="line">160</div><div class="line">161</div><div class="line">162</div><div class="line">163</div><div class="line">164</div><div class="line">165</div><div class="line">166</div><div class="line">167</div><div class="line">168</div><div class="line">169</div><div class="line">170</div><div class="line">171</div><div class="line">172</div><div class="line">173</div><div class="line">174</div><div class="line">175</div><div class="line">176</div><div class="line">177</div><div class="line">178</div><div class="line">179</div><div class="line">180</div><div class="line">181</div><div class="line">182</div><div class="line">183</div><div class="line">184</div><div class="line">185</div><div class="line">186</div><div class="line">187</div><div class="line">188</div><div class="line">189</div><div class="line">190</div><div class="line">191</div><div class="line">192</div><div class="line">193</div><div class="line">194</div><div class="line">195</div><div class="line">196</div><div class="line">197</div><div class="line">198</div><div class="line">199</div><div class="line">200</div><div class="line">201</div><div class="line">202</div><div class="line">203</div><div class="line">204</div><div class="line">205</div><div class="line">206</div><div class="line">207</div><div class="line">208</div><div class="line">209</div><div class="line">210</div><div class="line">211</div><div class="line">212</div><div class="line">213</div><div class="line">214</div><div class="line">215</div><div class="line">216</div><div class="line">217</div><div class="line">218</div><div class="line">219</div><div class="line">220</div><div class="line">221</div><div class="line">222</div><div class="line">223</div><div class="line">224</div><div class="line">225</div><div class="line">226</div><div class="line">227</div><div class="line">228</div><div class="line">229</div><div class="line">230</div><div class="line">231</div><div class="line">232</div><div class="line">233</div><div class="line">234</div><div class="line">235</div><div class="line">236</div><div class="line">237</div><div class="line">238</div><div class="line">239</div><div class="line">240</div><div class="line">241</div><div class="line">242</div><div class="line">243</div><div class="line">244</div><div class="line">245</div><div class="line">246</div><div class="line">247</div><div class="line">248</div><div class="line">249</div><div class="line">250</div><div class="line">251</div><div class="line">252</div><div class="line">253</div><div class="line">254</div><div class="line">255</div><div class="line">256</div><div class="line">257</div><div class="line">258</div><div class="line">259</div><div class="line">260</div><div class="line">261</div><div class="line">262</div><div class="line">263</div><div class="line">264</div><div class="line">265</div><div class="line">266</div><div class="line">267</div><div class="line">268</div><div class="line">269</div><div class="line">270</div><div class="line">271</div><div class="line">272</div><div class="line">273</div><div class="line">274</div><div class="line">275</div><div class="line">276</div><div class="line">277</div><div class="line">278</div><div class="line">279</div><div class="line">280</div><div class="line">281</div><div class="line">282</div><div class="line">283</div><div class="line">284</div><div class="line">285</div><div class="line">286</div><div class="line">287</div><div class="line">288</div><div class="line">289</div><div class="line">290</div><div class="line">291</div><div class="line">292</div><div class="line">293</div><div class="line">294</div><div class="line">295</div><div class="line">296</div><div class="line">297</div><div class="line">298</div><div class="line">299</div><div class="line">300</div><div class="line">301</div><div class="line">302</div><div class="line">303</div><div class="line">304</div><div class="line">305</div><div class="line">306</div><div class="line">307</div><div class="line">308</div><div class="line">309</div><div class="line">310</div><div class="line">311</div><div class="line">312</div><div class="line">313</div><div class="line">314</div><div class="line">315</div><div class="line">316</div><div class="line">317</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/* 引用头文件 *****************************************************************/</span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">"externalcount.h"</span></span></div><div class="line"><span class="comment">/* 私有数据类型 ***************************************************************/</span></div><div class="line"><span class="comment">/* 私有常数宏 *****************************************************************/</span></div><div class="line"><span class="comment">/* 私有动作宏 *****************************************************************/</span></div><div class="line"><span class="meta">#<span class="meta-keyword">define</span> ADC1_DR_Address    0x40012440</span></div><div class="line"><span class="comment">/* 私有变量 *******************************************************************/</span></div><div class="line"><span class="comment">/* 全局变量 */</span></div><div class="line"><span class="comment">/* 私有函数声明 ***************************************************************/</span></div><div class="line"><span class="comment">/* 私有函数  ******************************************************************/</span></div><div class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">ExternalcountClock</span><span class="params">(GPIO_TypeDef* port)</span></span>&#123;</div><div class="line">    <span class="keyword">if</span> (port == GPIOA)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);</div><div class="line">    <span class="keyword">else</span> <span class="keyword">if</span>(port == GPIOB)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);</div><div class="line">    <span class="keyword">else</span> <span class="keyword">if</span>(port == GPIOC)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);</div><div class="line">    <span class="keyword">else</span> <span class="keyword">if</span>(port == GPIOD)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE);</div><div class="line">    <span class="keyword">else</span> <span class="keyword">if</span>(port == GPIOE)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE, ENABLE);</div><div class="line">    <span class="keyword">else</span> <span class="keyword">if</span>(port == GPIOF)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">ExternalcountAf</span><span class="params">(Stdexternalcount_pin_TypeDef P)</span> </span>&#123;</div><div class="line">    <span class="keyword">uint8_t</span> af_num = <span class="number">0</span>;</div><div class="line">    <span class="keyword">switch</span>(P.pin) &#123;</div><div class="line">        <span class="keyword">case</span> GPIO_Pin_0:</div><div class="line">            af_num = <span class="number">0</span>;</div><div class="line">        <span class="keyword">break</span>;</div><div class="line">        <span class="keyword">case</span> GPIO_Pin_1:</div><div class="line">            af_num = <span class="number">1</span>;</div><div class="line">        <span class="keyword">break</span>;</div><div class="line">        <span class="keyword">case</span> GPIO_Pin_2:</div><div class="line">            af_num = <span class="number">2</span>;</div><div class="line">        <span class="keyword">break</span>;</div><div class="line">        <span class="keyword">case</span> GPIO_Pin_3:</div><div class="line">            af_num = <span class="number">3</span>;</div><div class="line">        <span class="keyword">break</span>;</div><div class="line">        <span class="keyword">case</span> GPIO_Pin_4:</div><div class="line">            af_num = <span class="number">4</span>;</div><div class="line">        <span class="keyword">break</span>;</div><div class="line">        <span class="keyword">case</span> GPIO_Pin_5:</div><div class="line">            af_num = <span class="number">5</span>;</div><div class="line">        <span class="keyword">break</span>;</div><div class="line">        <span class="keyword">case</span> GPIO_Pin_6:</div><div class="line">            af_num = <span class="number">6</span>;</div><div class="line">        <span class="keyword">break</span>;</div><div class="line">        <span class="keyword">case</span> GPIO_Pin_7:</div><div class="line">            af_num = <span class="number">7</span>;</div><div class="line">        <span class="keyword">break</span>;</div><div class="line">        <span class="keyword">case</span> GPIO_Pin_8:</div><div class="line">            af_num = <span class="number">8</span>;</div><div class="line">        <span class="keyword">break</span>;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">if</span>(P.port == GPIOA) &#123;</div><div class="line">        GPIO_PinAFConfig(P.port,af_num,GPIO_AF_2);</div><div class="line">    &#125; <span class="keyword">else</span> <span class="keyword">if</span>(P.port == GPIOB) &#123;</div><div class="line">        GPIO_PinAFConfig(P.port,af_num,GPIO_AF_1);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">ExternalcountInit</span><span class="params">(Stdexternalcount_n* externalcount)</span> </span>&#123;</div><div class="line">    GPIO_InitTypeDef    GPIO_InitStructure;</div><div class="line">    EXTI_InitTypeDef   EXTI_InitStructure;</div><div class="line">    NVIC_InitTypeDef   NVIC_InitStructure;</div><div class="line"><span class="comment">//    TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    TIM_ICInitTypeDef  TIM_ICInitStructure;</span></div><div class="line"><span class="comment">//    NVIC_InitTypeDef NVIC_InitStructure;</span></div><div class="line">    </div><div class="line">    ExternalcountClock(externalcount-&gt;XC1.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC2.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC3.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC4.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC5.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC6.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC7.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC8.port);</div><div class="line">    </div><div class="line"><span class="comment">//    /* TIM2 clock enable */</span></div><div class="line"><span class="comment">//    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);</span></div><div class="line"><span class="comment">//    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);</span></div><div class="line">    </div><div class="line">    <span class="comment">/* Enable SYSCFG clock */</span></div><div class="line">    RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;</div><div class="line">    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;</div><div class="line">    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;</div><div class="line">    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC1.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC1.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC2.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC2.port, &amp;GPIO_InitStructure);</div><div class="line">   </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC3.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC3.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC4.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC4.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC5.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC5.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC6.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC6.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC7.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC7.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC8.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC8.port, &amp;GPIO_InitStructure);</div><div class="line"><span class="comment">//    //打开端口复用</span></div><div class="line"><span class="comment">//    ExternalcountAf(externalcount-&gt;XC1);</span></div><div class="line"><span class="comment">//    ExternalcountAf(externalcount-&gt;XC2);</span></div><div class="line"><span class="comment">//    ExternalcountAf(externalcount-&gt;XC3);</span></div><div class="line"><span class="comment">//    ExternalcountAf(externalcount-&gt;XC4);</span></div><div class="line"><span class="comment">//    ExternalcountAf(externalcount-&gt;XC5);</span></div><div class="line"><span class="comment">//    ExternalcountAf(externalcount-&gt;XC6);</span></div><div class="line"><span class="comment">//    ExternalcountAf(externalcount-&gt;XC7);</span></div><div class="line"><span class="comment">//    ExternalcountAf(externalcount-&gt;XC8);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    TIM_TimeBaseStructure.TIM_Prescaler = 170 - 1;</span></div><div class="line"><span class="comment">//    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;</span></div><div class="line"><span class="comment">//    TIM_TimeBaseStructure.TIM_Period = 0xffffffff;</span></div><div class="line"><span class="comment">//    TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;</span></div><div class="line"><span class="comment">//    TIM_TimeBaseInit(TIM2, &amp;TIM_TimeBaseStructure);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    TIM_TimeBaseStructure.TIM_Prescaler = 170 - 1;</span></div><div class="line"><span class="comment">//    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;</span></div><div class="line"><span class="comment">//    TIM_TimeBaseStructure.TIM_Period = 0xffffffff;</span></div><div class="line"><span class="comment">//    TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;</span></div><div class="line"><span class="comment">//    TIM_TimeBaseInit(TIM3, &amp;TIM_TimeBaseStructure);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    /* Enable the TIM1 global Interrupt */</span></div><div class="line"><span class="comment">//    NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;</span></div><div class="line"><span class="comment">//    NVIC_InitStructure.NVIC_IRQChannelPriority = 0;</span></div><div class="line"><span class="comment">//    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;</span></div><div class="line"><span class="comment">//    NVIC_Init(&amp;NVIC_InitStructure);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//     /* Enable the TIM1 global Interrupt */</span></div><div class="line"><span class="comment">//    NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;</span></div><div class="line"><span class="comment">//    NVIC_InitStructure.NVIC_IRQChannelPriority = 0;</span></div><div class="line"><span class="comment">//    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;</span></div><div class="line"><span class="comment">//    NVIC_Init(&amp;NVIC_InitStructure);</span></div><div class="line"><span class="comment">//    /* TIM1 configuration: Input Capture mode ---------------------</span></div><div class="line"><span class="comment">//    The external signal is connected to TIM1 CH2 pin (PA.09)  </span></div><div class="line"><span class="comment">//    The Rising edge is used as active edge,</span></div><div class="line"><span class="comment">//    The TIM1 CCR2 is used to compute the frequency value </span></div><div class="line"><span class="comment">//    ------------------------------------------------------------ */</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICFilter = 0x0;</span></div><div class="line"><span class="comment">//    TIM_ICInit(TIM2, &amp;TIM_ICInitStructure);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICFilter = 0x0;</span></div><div class="line"><span class="comment">//    TIM_ICInit(TIM2, &amp;TIM_ICInitStructure);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_Channel = TIM_Channel_3;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICFilter = 0x0;</span></div><div class="line"><span class="comment">//    TIM_ICInit(TIM2, &amp;TIM_ICInitStructure);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_Channel = TIM_Channel_4;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICFilter = 0x0;</span></div><div class="line"><span class="comment">//    TIM_ICInit(TIM2, &amp;TIM_ICInitStructure);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    /* TIM enable counter */</span></div><div class="line"><span class="comment">//    TIM_Cmd(TIM2, ENABLE);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    /* Enable the CC2 Interrupt Request */</span></div><div class="line"><span class="comment">//    TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE);</span></div><div class="line"><span class="comment">//    TIM_ITConfig(TIM2, TIM_IT_CC2, ENABLE);</span></div><div class="line"><span class="comment">//    TIM_ITConfig(TIM2, TIM_IT_CC3, ENABLE);</span></div><div class="line"><span class="comment">//    TIM_ITConfig(TIM2, TIM_IT_CC4, ENABLE);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;</span></div><div class="line"><span class="comment">//    TIM_ICInitStructure.TIM_ICFilter = 0x0;</span></div><div class="line"><span class="comment">//    TIM_ICInit(TIM3, &amp;TIM_ICInitStructure);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    /* TIM enable counter */</span></div><div class="line"><span class="comment">//    TIM_Cmd(TIM3, ENABLE);</span></div><div class="line"><span class="comment">//    </span></div><div class="line"><span class="comment">//    /* Enable the CC2 Interrupt Request */</span></div><div class="line"><span class="comment">//    TIM_ITConfig(TIM3, TIM_IT_CC1, ENABLE);</span></div><div class="line">    <span class="comment">/* Configure EXTI0 line */</span></div><div class="line">    EXTI_InitStructure.EXTI_Line = EXTI_Line0;</div><div class="line">    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;</div><div class="line">    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;</div><div class="line">    EXTI_InitStructure.EXTI_LineCmd = ENABLE;</div><div class="line">    EXTI_Init(&amp;EXTI_InitStructure);</div><div class="line">    </div><div class="line">    <span class="comment">/* Enable and set EXTI0 Interrupt */</span></div><div class="line">    NVIC_InitStructure.NVIC_IRQChannel = EXTI0_1_IRQn;</div><div class="line">    NVIC_InitStructure.NVIC_IRQChannelPriority = <span class="number">0x00</span>;</div><div class="line">    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;</div><div class="line">    NVIC_Init(&amp;NVIC_InitStructure);</div><div class="line">    </div><div class="line">     <span class="comment">/* Connect EXTI0 Line to PA0 pin */</span></div><div class="line">    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="keyword">uint32_t</span> Rc_Pwm_In[<span class="number">8</span>];</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">ExternalcountRead</span><span class="params">(Stdexternalcount_n* externalcount,<span class="keyword">uint8_t</span> num)</span> </span>&#123;</div><div class="line">    externalcount-&gt;XC1.val = Rc_Pwm_In[<span class="number">0</span>];</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="comment">//void TIM3_IRQHandler(void) &#123;</span></div><div class="line"><span class="comment">//    static uint32_t temp3_cnt1,temp3_cnt1_2;</span></div><div class="line"><span class="comment">//    if(TIM_GetITStatus(TIM3, TIM_IT_CC1) == SET) &#123;</span></div><div class="line"><span class="comment">//        /* Clear TIM1 Capture compare interrupt pending bit */</span></div><div class="line"><span class="comment">//        TIM_ClearITPendingBit(TIM3, TIM_IT_CC1);</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">//        if(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_4) == 1) &#123;</span></div><div class="line"><span class="comment">//            TIM_OC1PolarityConfig(TIM3,TIM_ICPolarity_Falling);</span></div><div class="line"><span class="comment">//            temp3_cnt1 = TIM_GetCapture1(TIM3); </span></div><div class="line"><span class="comment">//        &#125; else &#123;</span></div><div class="line"><span class="comment">//            TIM_OC1PolarityConfig(TIM3,TIM_ICPolarity_Rising);</span></div><div class="line"><span class="comment">//            temp3_cnt1_2 = TIM_GetCapture1(TIM3);</span></div><div class="line"><span class="comment">//            </span></div><div class="line"><span class="comment">//            if(temp3_cnt1_2&gt;=temp3_cnt1)</span></div><div class="line"><span class="comment">//                Rc_Pwm_In[4] = temp3_cnt1_2-temp3_cnt1;</span></div><div class="line"><span class="comment">//            else</span></div><div class="line"><span class="comment">//                Rc_Pwm_In[4] = 0xffff-temp3_cnt1+temp3_cnt1_2+1;</span></div><div class="line"><span class="comment">//        &#125;</span></div><div class="line"><span class="comment">//    &#125; </span></div><div class="line"><span class="comment">//&#125;</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">//void TIM2_IRQHandler(void)</span></div><div class="line"><span class="comment">//&#123;       </span></div><div class="line"><span class="comment">//    static uint32_t temp_cnt1,temp_cnt1_2,temp_cnt2,temp_cnt2_2,temp_cnt3,temp_cnt3_2,temp_cnt4,temp_cnt4_2;</span></div><div class="line"><span class="comment">//    if(TIM_GetITStatus(TIM2, TIM_IT_CC1) == SET) &#123;</span></div><div class="line"><span class="comment">//        /* Clear TIM1 Capture compare interrupt pending bit */</span></div><div class="line"><span class="comment">//        TIM_ClearITPendingBit(TIM2, TIM_IT_CC1);</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">//        if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == 1) &#123;</span></div><div class="line"><span class="comment">//            TIM_OC1PolarityConfig(TIM2,TIM_ICPolarity_Falling);</span></div><div class="line"><span class="comment">//            temp_cnt3 = TIM_GetCapture1(TIM2); </span></div><div class="line"><span class="comment">//        &#125; else &#123;</span></div><div class="line"><span class="comment">//            TIM_OC1PolarityConfig(TIM2,TIM_ICPolarity_Rising);</span></div><div class="line"><span class="comment">//            temp_cnt3_2 = TIM_GetCapture1(TIM2);</span></div><div class="line"><span class="comment">//            if(temp_cnt3_2&gt;=temp_cnt3)</span></div><div class="line"><span class="comment">//                Rc_Pwm_In[2] = temp_cnt3_2-temp_cnt3;</span></div><div class="line"><span class="comment">//            else</span></div><div class="line"><span class="comment">//                Rc_Pwm_In[2] = 0xffff-temp_cnt3+temp_cnt3_2+1;</span></div><div class="line"><span class="comment">//        &#125;</span></div><div class="line"><span class="comment">//    &#125; else if(TIM_GetITStatus(TIM2, TIM_IT_CC3) == SET) </span></div><div class="line"><span class="comment">//    &#123;</span></div><div class="line"><span class="comment">//        /* Clear TIM1 Capture compare interrupt pending bit */</span></div><div class="line"><span class="comment">//        TIM_ClearITPendingBit(TIM2, TIM_IT_CC3);</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">//        if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_2) == 1) &#123;</span></div><div class="line"><span class="comment">//            TIM_OC3PolarityConfig(TIM2,TIM_ICPolarity_Falling);</span></div><div class="line"><span class="comment">//            temp_cnt2 = TIM_GetCapture3(TIM2); </span></div><div class="line"><span class="comment">//        &#125; else &#123;</span></div><div class="line"><span class="comment">//            TIM_OC3PolarityConfig(TIM2,TIM_ICPolarity_Rising);</span></div><div class="line"><span class="comment">//            temp_cnt2_2 = TIM_GetCapture3(TIM2);</span></div><div class="line"><span class="comment">//            if(temp_cnt2_2&gt;=temp_cnt2)</span></div><div class="line"><span class="comment">//                Rc_Pwm_In[1] = temp_cnt2_2-temp_cnt2;</span></div><div class="line"><span class="comment">//            else</span></div><div class="line"><span class="comment">//                Rc_Pwm_In[1] = 0xffff-temp_cnt2+temp_cnt2_2+1;</span></div><div class="line"><span class="comment">//        &#125;</span></div><div class="line"><span class="comment">//    &#125; else if(TIM_GetITStatus(TIM2, TIM_IT_CC2) == SET) &#123;</span></div><div class="line"><span class="comment">//        /* Clear TIM1 Capture compare interrupt pending bit */</span></div><div class="line"><span class="comment">//        TIM_ClearITPendingBit(TIM2, TIM_IT_CC2);</span></div><div class="line"><span class="comment">//        </span></div><div class="line"><span class="comment">//        if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_1) == 1) &#123;</span></div><div class="line"><span class="comment">//            TIM_OC2PolarityConfig(TIM2,TIM_ICPolarity_Falling);		//CC1P=1 设置为下降沿捕获</span></div><div class="line"><span class="comment">//            temp_cnt1 = TIM_GetCapture2(TIM2); </span></div><div class="line"><span class="comment">//        &#125; else &#123;</span></div><div class="line"><span class="comment">//            TIM_OC2PolarityConfig(TIM2,TIM_ICPolarity_Rising); //CC1P=0 设置为上升沿捕获</span></div><div class="line"><span class="comment">//            temp_cnt1_2 = TIM_GetCapture2(TIM2);</span></div><div class="line"><span class="comment">//            if(temp_cnt1_2&gt;=temp_cnt1)</span></div><div class="line"><span class="comment">//                Rc_Pwm_In[0] = temp_cnt1_2-temp_cnt1;</span></div><div class="line"><span class="comment">//            else</span></div><div class="line"><span class="comment">//                Rc_Pwm_In[0] = 0xffff-temp_cnt1+temp_cnt1_2+1;</span></div><div class="line"><span class="comment">//        &#125;</span></div><div class="line"><span class="comment">//    &#125; else if(TIM_GetITStatus(TIM2, TIM_IT_CC4) == SET) &#123;</span></div><div class="line"><span class="comment">//        /* Clear TIM1 Capture compare interrupt pending bit */</span></div><div class="line"><span class="comment">//        TIM_ClearITPendingBit(TIM2, TIM_IT_CC4);</span></div><div class="line"><span class="comment">//        </span></div><div class="line"><span class="comment">//        if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_3) == 1) &#123;</span></div><div class="line"><span class="comment">//            TIM_OC4PolarityConfig(TIM2,TIM_ICPolarity_Falling);		//CC1P=1 设置为下降沿捕获</span></div><div class="line"><span class="comment">//            temp_cnt4 = TIM_GetCapture4(TIM2); </span></div><div class="line"><span class="comment">//        &#125; else &#123;</span></div><div class="line"><span class="comment">//            TIM_OC4PolarityConfig(TIM2,TIM_ICPolarity_Rising); //CC1P=0 设置为上升沿捕获</span></div><div class="line"><span class="comment">//            temp_cnt4_2 = TIM_GetCapture4(TIM2);</span></div><div class="line"><span class="comment">//            if(temp_cnt4_2&gt;=temp_cnt4)</span></div><div class="line"><span class="comment">//                Rc_Pwm_In[3] = temp_cnt4_2-temp_cnt4;</span></div><div class="line"><span class="comment">//            else</span></div><div class="line"><span class="comment">//                Rc_Pwm_In[3] = 0xffff-temp_cnt4+temp_cnt4_2+1;</span></div><div class="line"><span class="comment">//        &#125;</span></div><div class="line"><span class="comment">//    &#125;</span></div><div class="line"><span class="comment">//&#125;</span></div><div class="line"><span class="comment">/***************************************************************END OF FILE****/</span></div></pre></td></tr></table></figure>
<ul>
<li>外部中断</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div><div class="line">151</div><div class="line">152</div><div class="line">153</div><div class="line">154</div><div class="line">155</div><div class="line">156</div><div class="line">157</div><div class="line">158</div><div class="line">159</div><div class="line">160</div><div class="line">161</div><div class="line">162</div><div class="line">163</div><div class="line">164</div><div class="line">165</div><div class="line">166</div><div class="line">167</div><div class="line">168</div><div class="line">169</div><div class="line">170</div><div class="line">171</div><div class="line">172</div><div class="line">173</div><div class="line">174</div><div class="line">175</div><div class="line">176</div><div class="line">177</div><div class="line">178</div><div class="line">179</div><div class="line">180</div><div class="line">181</div><div class="line">182</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/* 引用头文件 *****************************************************************/</span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">"externalcount.h"</span></span></div><div class="line"><span class="comment">/* 私有数据类型 ***************************************************************/</span></div><div class="line"><span class="comment">/* 私有常数宏 *****************************************************************/</span></div><div class="line"><span class="comment">/* 私有动作宏 *****************************************************************/</span></div><div class="line"><span class="meta">#<span class="meta-keyword">define</span> ADC1_DR_Address    0x40012440</span></div><div class="line"><span class="comment">/* 私有变量 *******************************************************************/</span></div><div class="line"><span class="comment">/* 全局变量 */</span></div><div class="line"><span class="comment">/* 私有函数声明 ***************************************************************/</span></div><div class="line"><span class="comment">/* 私有函数  ******************************************************************/</span></div><div class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">ExternalcountClock</span><span class="params">(GPIO_TypeDef* port)</span></span>&#123;</div><div class="line">    <span class="keyword">if</span> (port == GPIOA)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);</div><div class="line">    <span class="keyword">else</span> <span class="keyword">if</span>(port == GPIOB)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);</div><div class="line">    <span class="keyword">else</span> <span class="keyword">if</span>(port == GPIOC)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);</div><div class="line">    <span class="keyword">else</span> <span class="keyword">if</span>(port == GPIOD)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE);</div><div class="line">    <span class="keyword">else</span> <span class="keyword">if</span>(port == GPIOE)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE, ENABLE);</div><div class="line">    <span class="keyword">else</span> <span class="keyword">if</span>(port == GPIOF)</div><div class="line">        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">ExternalcountInit</span><span class="params">(Stdexternalcount_n* externalcount)</span> </span>&#123;</div><div class="line">    GPIO_InitTypeDef    GPIO_InitStructure;</div><div class="line">    EXTI_InitTypeDef   EXTI_InitStructure;</div><div class="line">    NVIC_InitTypeDef   NVIC_InitStructure;</div><div class="line">    </div><div class="line">    ExternalcountClock(externalcount-&gt;XC1.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC2.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC3.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC4.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC5.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC6.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC7.port);</div><div class="line">    ExternalcountClock(externalcount-&gt;XC8.port);</div><div class="line">    </div><div class="line">    <span class="comment">/* Enable SYSCFG clock */</span></div><div class="line">    RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;</div><div class="line">    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC1.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC1.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC2.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC2.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC3.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC3.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC4.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC4.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC5.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC5.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC6.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC6.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC7.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC7.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    GPIO_InitStructure.GPIO_Pin = externalcount-&gt;XC8.pin;</div><div class="line">    GPIO_Init(externalcount-&gt;XC8.port, &amp;GPIO_InitStructure);</div><div class="line">    </div><div class="line">    <span class="comment">/* Configure EXTI0 line */</span></div><div class="line">    EXTI_InitStructure.EXTI_Line = EXTI_Line0;</div><div class="line">    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;</div><div class="line">    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;</div><div class="line">    EXTI_InitStructure.EXTI_LineCmd = ENABLE;</div><div class="line">    EXTI_Init(&amp;EXTI_InitStructure);</div><div class="line">    <span class="comment">/* Configure EXTI0 line */</span></div><div class="line">    EXTI_InitStructure.EXTI_Line = EXTI_Line1;</div><div class="line">    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;</div><div class="line">    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;</div><div class="line">    EXTI_InitStructure.EXTI_LineCmd = ENABLE;</div><div class="line">    EXTI_Init(&amp;EXTI_InitStructure);</div><div class="line">    <span class="comment">/* Configure EXTI0 line */</span></div><div class="line">    EXTI_InitStructure.EXTI_Line = EXTI_Line2;</div><div class="line">    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;</div><div class="line">    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;</div><div class="line">    EXTI_InitStructure.EXTI_LineCmd = ENABLE;</div><div class="line">    EXTI_Init(&amp;EXTI_InitStructure);</div><div class="line">    <span class="comment">/* Configure EXTI0 line */</span></div><div class="line">    EXTI_InitStructure.EXTI_Line = EXTI_Line3;</div><div class="line">    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;</div><div class="line">    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;</div><div class="line">    EXTI_InitStructure.EXTI_LineCmd = ENABLE;</div><div class="line">    EXTI_Init(&amp;EXTI_InitStructure);</div><div class="line">    <span class="comment">/* Configure EXTI0 line */</span></div><div class="line">    EXTI_InitStructure.EXTI_Line = EXTI_Line4;</div><div class="line">    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;</div><div class="line">    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;</div><div class="line">    EXTI_InitStructure.EXTI_LineCmd = ENABLE;</div><div class="line">    EXTI_Init(&amp;EXTI_InitStructure);</div><div class="line">    <span class="comment">/* Configure EXTI0 line */</span></div><div class="line">    EXTI_InitStructure.EXTI_Line = EXTI_Line6;</div><div class="line">    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;</div><div class="line">    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;</div><div class="line">    EXTI_InitStructure.EXTI_LineCmd = ENABLE;</div><div class="line">    EXTI_Init(&amp;EXTI_InitStructure);</div><div class="line">    </div><div class="line">    <span class="comment">/* Enable and set EXTI0 Interrupt */</span></div><div class="line">    NVIC_InitStructure.NVIC_IRQChannel = EXTI0_1_IRQn;</div><div class="line">    NVIC_InitStructure.NVIC_IRQChannelPriority = <span class="number">0x00</span>;</div><div class="line">    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;</div><div class="line">    NVIC_Init(&amp;NVIC_InitStructure);</div><div class="line">    </div><div class="line">    <span class="comment">/* Enable and set EXTI0 Interrupt */</span></div><div class="line">    NVIC_InitStructure.NVIC_IRQChannel = EXTI2_3_IRQn;</div><div class="line">    NVIC_InitStructure.NVIC_IRQChannelPriority = <span class="number">0x00</span>;</div><div class="line">    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;</div><div class="line">    NVIC_Init(&amp;NVIC_InitStructure);</div><div class="line">    </div><div class="line">    <span class="comment">/* Enable and set EXTI0 Interrupt */</span></div><div class="line">    NVIC_InitStructure.NVIC_IRQChannel = EXTI4_15_IRQn;</div><div class="line">    NVIC_InitStructure.NVIC_IRQChannelPriority = <span class="number">0x00</span>;</div><div class="line">    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;</div><div class="line">    NVIC_Init(&amp;NVIC_InitStructure);</div><div class="line">    </div><div class="line">    <span class="comment">/* Connect EXTI0 Line to PA0 pin */</span></div><div class="line">    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);</div><div class="line">    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource1);</div><div class="line">    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource2);</div><div class="line">    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource3);</div><div class="line">    </div><div class="line">    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource0);</div><div class="line">    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource1);</div><div class="line">    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource4);</div><div class="line">    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource5);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="keyword">uint32_t</span> Rc_Pwm_In[<span class="number">8</span>];</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">ExternalcountRead</span><span class="params">(Stdexternalcount_n* externalcount,<span class="keyword">uint8_t</span> num)</span> </span>&#123;</div><div class="line">    externalcount-&gt;XC1.val = Rc_Pwm_In[<span class="number">0</span>];</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">EXTI0_1_IRQHandler</span><span class="params">(<span class="keyword">void</span>)</span></span></div><div class="line">&#123;</div><div class="line">    <span class="keyword">if</span>(EXTI_GetITStatus(EXTI_Line0) != RESET) &#123;</div><div class="line">        </div><div class="line">        <span class="comment">/* Clear the EXTI line 0 pending bit */</span></div><div class="line">        EXTI_ClearITPendingBit(EXTI_Line0);</div><div class="line">    &#125; <span class="keyword">else</span> <span class="keyword">if</span>(EXTI_GetITStatus(EXTI_Line1) != RESET) &#123;</div><div class="line">        </div><div class="line">        <span class="comment">/* Clear the EXTI line 0 pending bit */</span></div><div class="line">        EXTI_ClearITPendingBit(EXTI_Line1);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">EXTI2_3_IRQHandler</span><span class="params">(<span class="keyword">void</span>)</span></span></div><div class="line">&#123;</div><div class="line">    <span class="keyword">if</span>(EXTI_GetITStatus(EXTI_Line2) != RESET) &#123;</div><div class="line">        </div><div class="line">        <span class="comment">/* Clear the EXTI line 0 pending bit */</span></div><div class="line">        EXTI_ClearITPendingBit(EXTI_Line2);</div><div class="line">    &#125; <span class="keyword">else</span> <span class="keyword">if</span>(EXTI_GetITStatus(EXTI_Line3) != RESET) &#123;</div><div class="line">        </div><div class="line">        <span class="comment">/* Clear the EXTI line 0 pending bit */</span></div><div class="line">        EXTI_ClearITPendingBit(EXTI_Line3);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">EXTI4_15_IRQHandler</span><span class="params">(<span class="keyword">void</span>)</span></span></div><div class="line">&#123;</div><div class="line">    <span class="keyword">if</span>(EXTI_GetITStatus(EXTI_Line4) != RESET) &#123;</div><div class="line">        </div><div class="line">        <span class="comment">/* Clear the EXTI line 0 pending bit */</span></div><div class="line">        EXTI_ClearITPendingBit(EXTI_Line4);</div><div class="line">    &#125; <span class="keyword">else</span> <span class="keyword">if</span>(EXTI_GetITStatus(EXTI_Line4) != RESET) &#123;</div><div class="line">        </div><div class="line">        <span class="comment">/* Clear the EXTI line 0 pending bit */</span></div><div class="line">        EXTI_ClearITPendingBit(EXTI_Line4);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="comment">/***************************************************************END OF FILE****/</span></div></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/C/" rel="tag"># C</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/08/19/编程的核心/" rel="next" title="编程的核心">
                <i class="fa fa-chevron-left"></i> 编程的核心
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/08/19/coos-手册阅读/" rel="prev" title="coos 手册阅读">
                coos 手册阅读 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="linghaibin" />
          <p class="site-author-name" itemprop="name">linghaibin</p>
           
              <p class="site-description motion-element" itemprop="description">不要停止阅读</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives/">
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">2</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/dh-linghaibin" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#stm32f0-寄存器配置"><span class="nav-number">1.</span> <span class="nav-text">stm32f0 寄存器配置</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">linghaibin</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
